package com.tfswue.chy.controller;

import com.tfswue.chy.entity.Order;
import com.tfswue.chy.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/api/orders")
public class OrderController {
    @Autowired
    private OrderService orderService;
    
    @Value("${server.port}")
    private String port;
    
    @GetMapping("/port")
    public String getPort() {
        return "端口: " + port;
    }
    @Value("${config.nacos}")
    private String nacos;

    @GetMapping("/config/info")
    public String getNacosConfig() {
        return nacos;
    }

    @GetMapping("/{id}")
    public Order getOrderById(@PathVariable("id") Integer id) {
        return orderService.getOrderById(id);
    }
    
    // 添加测试接口
    @GetMapping("/test")
    public String test() {
        return "order-server is working!";
    }
}
